package com.four.shop.controller;

import com.four.shop.entity.Format;
import com.four.shop.service.FormatService;
import com.guli.common.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
 * @Author:wsy
 * @Date: 2021/12/9/15:35
 */
@RestController
@RequestMapping("shop/format")
public class FormatController {
    @Autowired
    private FormatService formatService;
    /**
     * 添加规格
     *
     * @param format
     *
     * @return
     */
    @PostMapping("/formatadd")
    public R propertyadd(Format format){
        formatService.formatadd(format);
        return R.ok();
    }
    /**
     * 查询最大id
     *
     * @param
     *
     * @return
     */
    @GetMapping("/byId")
    public R formatadd2( ){

        Integer id= formatService.getById();
        return R.ok().put("id",id);
    }
    /**
     * 编辑规格
     *
     * @param format
     *
     * @return
     */
    @PostMapping("/formatupdate")
    public R formatupdate( Format format){
        formatService.formatupdate(format);
        return R.ok();
    }
    /**
     * 规格删除
     *
     * @param id
     *
     * @return
     */
    @DeleteMapping("/formatdel")
    public R formatdel(@RequestParam("id")int id){
        formatService.formatdel(id);
        return R.ok();
    }

}
